/******************** 变量 ********************/
$lv-modal-bg: $popup-background !default;
$lv-modal-title-color: $text-color !default;
$lv-modal-dialog-color: $text-color-secondary !default;
$lv-modal-splitline: transparent !default;

/******************** mixin ********************/

/******************** 组件 ********************/
.lv-modal-panel {
  -webkit-perspective: 12rem;
  -moz-perspective: 12rem;
  -ms-perspective: 12rem;
  -o-perspective: 12rem;
  perspective: 12rem;
}

.lv-modal {
  display: flex;
  flex-direction: column;
  width: 100%;
  margin: 0;
  padding: 0;
  min-width: 3.6rem;
  min-height: 1.2rem;
  border-radius: $border-radius-lg;
  background: $lv-modal-bg;
  box-shadow: 0 0.04rem 0.15rem 0 $overlay-backdrop-bg-color;
  font-size: $font-size-base;
  line-height: $line-height-base;
  font-family: $font-family;

  &.lv-modal-perserve {
    -webkit-transform-style: preserve-3d;
    -moz-transform-style: preserve-3d;
    -ms-transform-style: preserve-3d;
    -o-transform-style: preserve-3d;
    transform-style: preserve-3d;
  }

  .lv-modal-header {
    flex: 0 0 auto;
    position: relative;

    > .btn-close {
      position: absolute;
      top: 0.28rem;
      right: 0.24rem;
      line-height: 0;

      > button {
        height: 0.16rem;
        width: 0.16rem;
        padding: 0;
        min-width: 0;
        line-height: 0;
        border: 0;
        color: $text-color-secondary;

        i {
          @include icon-size;
        }
      }
    }

    > .lv-modal-title {
      display: flex;
      align-items: center;
      margin: $margin-lg $margin-lg 0;
      color: $lv-modal-title-color;
      font-weight: $font-weight-bold;
      font-size: $font-size-lg;
      line-height: $line-height-lg;

      > i {
        flex-shrink: 0;
        margin-right: $margin-sm;

        @include icon-size-md;
      }

      > span.lv-modal-title-info {
        display: block;
      }
    }
    .btn-close + .lv-modal-title {
      padding-right: 0.64rem;
    }
  }

  .lv-modal-header-drag {
    cursor: move;
  }

  .lv-modal-body {
    display: flex;
    flex: 1 1 auto;
    align-items: stretch;
    padding-top: $margin-md;

    .lv-modal-content {
      width: 100%;
      height: 100%;
      padding: 0 $padding-lg;
      overflow: auto;
      color: $lv-modal-dialog-color;
      word-wrap: break-word;
      word-break: break-word;

      @include component-scroll;
    }

    &.lv-modal-no-header {
      padding-top: $margin-lg;

      &:not(.lv-modal-no-close-button) .lv-modal-content {
        padding-right: $padding-lg + $padding-xl;
      }
    }

    &.lv-modal-no-footer {
      padding-bottom: $margin-lg;
    }
  }

  .lv-modal-footer {
    flex: 0 0 auto;

    > .lv-modal-btns {
      padding: $padding-md $padding-lg $padding-lg;
      display: flex;
      align-items: center;
      justify-content: flex-end;

      > .lv-modal-btn-item {
        margin-left: $margin-md;
      }

      &.lv-modal-btns-default {
        justify-content: flex-start;
        flex-direction: row-reverse;
      }
    }
  }

  &.lv-modal-has-icon {
    .lv-modal-body {
      .lv-modal-content {
        padding: 0 0.56rem;
      }
    }
  }
}

.lv-modal-mask-no-transparent {
  box-shadow: none;
}

// Drawer Style
.lv-modal.lv-modal-drawer {
  width: 100%;
  height: 100%;
  border-radius: 0;

  .lv-modal-header {
    > .btn-close {
      top: 0.26rem;

      > button,
      > button i {
        @include icon-size-md;
      }
    }

    > .lv-modal-title {
      margin: $margin-lg $margin-lg $margin-md;
      font-size: $font-size-xl;
      line-height: $line-height-xl;
    }

    &.lv-modal-no-header {
      > .btn-close {
        top: 0.24rem;
      }
    }
  }

  .lv-modal-body {
    padding-top: 0;

    .lv-modal-content {
      padding: 0 $padding-lg;
      @include component-scroll-lg;
    }

    &.lv-modal-no-header {
      padding-top: $padding-lg;
    }
  }

  .lv-modal-drawer-body {
    flex-direction: column;

    &::after,
    &::before {
      content: '';
      display: block;
      margin: 0 $margin-xl;
      height: 0;
      font-size: 0;
      border-top: $border-width-base dashed $lv-modal-splitline;
    }

    &.lv-modal-no-header {
      &::before {
        border-top: none;
      }
    }

    &.lv-modal-no-footer {
      &::after {
        border-top: none;
      }
    }

    .lv-modal-content {
      width: auto;
    }
  }

  .lv-modal-footer {
    flex: 0 0 auto;

    > .lv-modal-btns {
      padding: $padding-md $padding-lg;
    }
  }
}

.lv-modal.cdk-drag-disabled {
  .cdk-drag-handle {
    user-select: auto !important;
  }
}

.lv-resize-handle {
  position: absolute;
  background: transparent;
  -webkit-touch-callout: none; /* iOS Safari */
  -webkit-user-select: none; /* Chrome/Safari/Opera */
  -khtml-user-select: none; /* Konqueror */
  -moz-user-select: none; /* Firefox */
  -ms-user-select: none; /* Internet Explorer/Edge */
  user-select: none;

  &-horizontal-right {
    width: 0.05rem;
    left: 0;
    top: 0;
    bottom: 0;
    cursor: col-resize;
  }

  &-horizontal-left {
    width: 0.05rem;
    right: 0;
    top: 0;
    bottom: 0;
    cursor: col-resize;
  }

  &-vertical-top {
    height: 0.05rem;
    left: 0;
    right: 0;
    bottom: 0;
    cursor: row-resize;
  }

  &-vertical-bottom {
    height: 0.05rem;
    left: 0;
    right: 0;
    top: 0;
    cursor: row-resize;
  }
}

// Dialog Style
.lv-modal.lv-modal-dialog {
  min-width: 3.6rem;
  min-height: 1.24rem;

  .lv-modal-body {
    .lv-modal-content {
      color: $lv-modal-dialog-color;
    }
  }
}

// Popover modal
.lv-modal-popover {
  &.lv-modal-popover-position {
    &-topLeft,
    &-top,
    &-topRight {
      margin-bottom: $margin-md;
    }

    &-rightTop,
    &-right,
    &-rightBottom {
      margin-left: $margin-md;
    }

    &-bottomLeft,
    &-bottom,
    &-bottomRight {
      margin-top: $margin-md;
    }

    &-leftTop,
    &-left,
    &-leftBottom {
      margin-right: $margin-md;
    }
  }
}
